using System;
using System.Collections.Generic;
using System.Text;
using Shc.Sql;
using Shc.Json;
namespace CLZ.Data
{
	public static class TableProductCategory
	{
		public const string Table = "ProductCategory";
		public const string ProductCategoryID = "ProductCategoryID";
		public const string CategoryName = "CategoryName";
		public const string Sort = "Sort";
	}
	
	[Serializable]
	public class BaseProductCategory
		: IDbSessionEntity, IJsonClass
	{
		int m_ProductCategoryID;
		/// <summary>
        /// 
        /// </summary>
        public int ProductCategoryID
        {
            get { return m_ProductCategoryID; }
            set { m_ProductCategoryID = value; }
        }
		
		string m_CategoryName;
		/// <summary>
        /// 
        /// </summary>
        public string CategoryName
        {
            get { return m_CategoryName; }
            set { m_CategoryName = value; }
        }
		
		int m_Sort;
		/// <summary>
        /// 
        /// </summary>
        public int Sort
        {
            get { return m_Sort; }
            set { m_Sort = value; }
        }
		
		
		#region IDbSessionEntity Members
		public void ReadDBData(RowDataReader reader)
        {
            m_ProductCategoryID = reader[TableProductCategory.ProductCategoryID];
            m_CategoryName = reader[TableProductCategory.CategoryName];
            m_Sort = reader[TableProductCategory.Sort];
        }
		
		public void WriteDBData(RowDataWriter writer)
        {
            writer.SetPrimaryKey(TableProductCategory.ProductCategoryID, PrimaryKeyType.Identity, ProductCategoryID);
			writer[TableProductCategory.CategoryName] = CategoryName;
			writer[TableProductCategory.Sort] = Sort;
        }

        public void SetIdentityAfterInsert(DBObject idd)
        {
            m_ProductCategoryID = idd;
        }
		
		public string TableName
        {
            get { return TableProductCategory.Table; }
        }
		#endregion
		
		#region IJsonClass Members

        public void JsonDeSerializeObj(JsonHashTable hashToRead)
        {
             m_ProductCategoryID = hashToRead["ProductCategoryID"];
			 
             m_CategoryName = hashToRead["CategoryName"];
			 
             m_Sort = hashToRead["Sort"];
			 
        }

        public void JsonSerializeObj(JsonHashTable hashToFill)
        {
            hashToFill["ProductCategoryID"] = ProductCategoryID;
			 
            hashToFill["CategoryName"] = CategoryName;
			 
            hashToFill["Sort"] = Sort;
			 
        }

        #endregion
		
	}
}
